package com.zkthink.ceres.order.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.zkthink.base.entity.Entity;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.zkthink.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 每个子订单下对应的商品
 * </p>
 *
 * @author JustArgo
 * @since 2020-05-17
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("ceres_order_product")
@ApiModel(value = "OrderProduct", description = "每个子订单下对应的商品")
@AllArgsConstructor
public class OrderProduct extends Entity<Long> {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("商户编号")
    @TableField("tenant_code")
    private String tenantCode;

    /**
     * 店铺id
     */
    @ApiModelProperty(value = "店铺id")
    @NotNull(message = "店铺id不能为空")
    @TableField("store_id")
    @Excel(name = "店铺id")
    private Long storeId;

    /**
     * 订单id
     */
    @ApiModelProperty(value = "订单id")
    @NotNull(message = "订单id不能为空")
    @TableField("order_id")
    @Excel(name = "订单id")
    private Long orderId;

    /**
     * 商品id
     */
    @ApiModelProperty(value = "商品id")
    @TableField("product_id")
    @Excel(name = "商品id")
    private Long productId;

    /**
     * 商品名称
     */
    @ApiModelProperty(value = "商品名称")
    @Length(max = 50, message = "商品名称长度不能超过50")
    @TableField(value = "product_name", condition = LIKE)
    @Excel(name = "商品名称")
    private String productName;

    /**
     * 商品sku对应的主键id
     */
    @ApiModelProperty(value = "商品sku对应的主键id")
    @TableField("sku_id")
    @Excel(name = "商品sku对应的主键id")
    private Long skuId;

    /**
     * 白色 37码
     */
    @ApiModelProperty(value = "白色 37码")
    @Length(max = 200, message = "白色 37码长度不能超过200")
    @TableField(value = "sku_name_str", condition = LIKE)
    @Excel(name = "白色 37码")
    private String skuNameStr;

    /**
     * sku对应的图片
     */
    @ApiModelProperty(value = "sku对应的图片")
    @NotEmpty(message = "sku对应的图片不能为空")
    @Length(max = 200, message = "sku对应的图片长度不能超过200")
    @TableField(value = "sku_img", condition = LIKE)
    @Excel(name = "sku对应的图片")
    private String skuImg;

    /**
     * 购买数量
     */
    @ApiModelProperty(value = "购买数量")
    @TableField("buy_num")
    @Excel(name = "购买数量")
    private Integer buyNum;

    /**
     * 重量，单位(千克)
     */
    @ApiModelProperty(value = "重量，单位(千克)")
    @NotNull(message = "重量，单位(千克)不能为空")
    @TableField("weight")
    @Excel(name = "重量，单位(千克)")
    private Double weight;

    /**
     * 原价
     */
    @ApiModelProperty(value = "原价")
    @TableField("apply_price")
    @Excel(name = "原价")
    private Long applyPrice;

    /**
     * 销售价
     */
    @ApiModelProperty(value = "销售价")
    @TableField("sell_price")
    @Excel(name = "销售价")
    private Long sellPrice;

    /**
     * 需要支付的运费
     */
    @ApiModelProperty(value = "需要支付的运费")
    @TableField("post_pay")
    @Excel(name = "需要支付的运费")
    private Long postPay;

    /**
     * 逻辑删除：1-删除 0-未删除
     */
    @ApiModelProperty(value = "逻辑删除：1-删除 0-未删除")
    @NotNull(message = "逻辑删除：1-删除 0-未删除不能为空")
    @TableField("is_delete")
    @Excel(name = "逻辑删除：1-删除 0-未删除")
    private Integer isDelete;

    /**
     * 消费金额
     */
    @ApiModelProperty(value = "消费金额")
    @TableField("discount_amount")
    @Excel(name = "消费金额")
    private Long discountAmount;


    @Builder
    public OrderProduct(Long id, Long createUser, LocalDateTime createTime, Long updateUser, LocalDateTime updateTime, 
                    Long storeId, Long orderId, Long productId, String productName, Long skuId, 
                    String skuNameStr, String skuImg, Integer buyNum, Double weight, Long applyPrice, Long sellPrice, 
                    Long postPay, Integer isDelete) {
        this.id = id;
        this.createUser = createUser;
        this.createTime = createTime;
        this.updateUser = updateUser;
        this.updateTime = updateTime;
        this.storeId = storeId;
        this.orderId = orderId;
        this.productId = productId;
        this.productName = productName;
        this.skuId = skuId;
        this.skuNameStr = skuNameStr;
        this.skuImg = skuImg;
        this.buyNum = buyNum;
        this.weight = weight;
        this.applyPrice = applyPrice;
        this.sellPrice = sellPrice;
        this.postPay = postPay;
        this.isDelete = isDelete;
    }

}
